package com.jy.wms.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jy.wms.common.annotions.BaseServiceDescribe;
import com.jy.wms.common.base.BaseService;
import com.jy.wms.common.base.ServiceException;
import com.jy.wms.dao.WmsAddressDictionaryMapper;
import com.jy.wms.pojo.WmsAddressDictionary;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
    * @ClassName: WmsAddressDictionaryService.java
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @Author Liyi
    * @Date Sat Oct 14 09:29:55 CST 2017
    */

    @Service
    public class WmsAddressDictionaryService extends BaseService<WmsAddressDictionaryMapper,WmsAddressDictionary> {

     /**
     * 插入一条记录
     * @param entity 实体对象
     * @return int
     */
    public Integer baseInsert(WmsAddressDictionary entity){
         return dao.baseInsert( entity );
    }

   /**
    * 插入一条记录（匹配有值的字段）
    * @param entity 实体对象
    * @return int
    */
    public Integer baseInsertSelective(WmsAddressDictionary entity){
         return dao.baseInsertSelective( entity);
    }

   /**
    * 删除（根据主键ID删除）
    * @param id 主键
    * @return int
    */
    public Integer baseDeleteByPrimaryKey(String id){
         return dao.baseDeleteByPrimaryKey( id);
    }

   /**
    * 删除（根据ID 批量删除）
    * @param idList 主键ID列表
    * @return int
    */
    public Integer baseDeleteBathPrimaryKeys(List<String> idList){
         return dao.baseDeleteBathPrimaryKeys( idList );
    }

    /**
    * 分页查询
    * @param entity 实体
    * @return Page<WmsAddressDictionary>
    */
    public Page<WmsAddressDictionary> baseSelectPage(WmsAddressDictionary entity ){
        PageHelper.startPage(entity.getPage(),entity.getRows());
        return (Page<WmsAddressDictionary>)dao.baseSelectPage( entity );
    }

   /**
    * 查询（根据主键ID查询）
    * @param id 主键ID
    * @return WmsAddressDictionary
    */
    public WmsAddressDictionary baseSelectByPrimaryKey(String id ){
         return dao.baseSelectByPrimaryKey( id );
    }

    /**
     * 查询所有的省
     * @return WmsAddressDictionary
     */
    @BaseServiceDescribe(moduleName = "城市操作",btnName = "查询所有的省")
    public List<Map<String,Object>> baseSelectAllProvince( )throws Exception {
        try {
            return dao.baseSelectAllProvince();
        } catch (Exception e) {
            throw new ServiceException("查询所有的省",e);
        }
    }

    /**
     * 根据省ID查询所有的城市
     * @return WmsAddressDictionary
     */
    @BaseServiceDescribe(moduleName = "城市操作",btnName = "根据省ID查询所有的城市")
    public List<Map<String,Object>> baseSelectCityByFjid(String fjid )throws Exception {
        try {
            return dao.baseSelectCityByFjid(fjid);
        } catch (Exception e) {
            throw new ServiceException("根据省ID查询所有的城市",e);
        }
    }

   /**
    * 查询（根据ID 批量查询）
    * @param idList 主键ID列表
    * @return list
    */
    public Integer baseSelectBathPrimaryKeys(List<WmsAddressDictionary> idList ){
         return dao.baseSelectBathPrimaryKeys( idList );
    }

   /**
    *修改 （匹配有值的字段）
    * @param entity 主键ID列表
    * @return int
    */
    public Integer baseUpdateByPrimaryKeySelective(WmsAddressDictionary entity){
         return dao.baseUpdateByPrimaryKeySelective( entity);
    }

   /**
    *修改（根据主键ID修改）
    * @param entity 主键ID列表
    * @return int
    */
    public Integer baseUpdateByPrimaryKey(WmsAddressDictionary entity){
         return dao.baseUpdateByPrimaryKey( entity);
    }
}
